package com.pace.eps.service.impl;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.pace.eps.service.OrderPayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class OrderPayServiceImpl implements OrderPayService {



    @Override
    @HystrixCommand(fallbackMethod = "pay_handler",commandProperties = {@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds",value = "1000")})
    public String pay(int i) {

        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "Thread"+Thread.currentThread().getName()+"id={}"+i;
    }


   public String pay_handler(int i){

        return "服务繁忙请稍后重试"+i;
    }
}
